home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
asm
/
demos
/
fractals
/
mandelbrot2.s
< prev
next >
Wrap
Text File
|
1980-01-03
|
6KB
|
330 lines
section TheCode,code
bsr.w TakeSystem
lea Bmap,a4
moveq #0,d4
move.l #-$8000000*2,a1
move.l #100,a2
move.l #8000,a3
;$1333333 each x
;$28f5c2 each y
move.l #$199999,d1
move.l #$28f5c2,d2
move.l #319,d5
moveq #$f,d6
moveq #7,d7
yloop: move.l d5,d3
move.l #$8000000*2,a0
xloop: move.l a2,d0
movem.l d1-d7/a2-a6,-(a7)
move.w d0,d3
moveq #0,d4 ; q1 = 0
moveq #0,d5 ; q2 = 0
moveq #0,d6 ; x = 0
moveq #0,d7 ; y = 0
subq.w #1,d3
mandelloop2: move.l d6,d1 ; D1 = oldx;
move.l d4,d6
sub.l d5,d6
add.l a0,d6 ; x(D6) = q1(D4) - q2(D5) + acoo(A0);
move.l d1,d2
bpl.b Pos1
neg.l d1
Pos1: eor.l d7,d2
tst.l d7
bpl.b Pos2
neg.l d7
Pos2: move.l d1,d0
swap d0
move.w d0,d2
mulu d7,d0
clr.w d0
swap d0
swap d7
mulu d7,d1
clr.w d1
swap d1
mulu d2,d7
add.l d0,d7
add.l d1,d7
tst.l d2
bpl.b Pos3
neg.l d7
Pos3: moveq #6,d0
asl.l d0,d7
add.l a1,d7 ; y(D7) = 2 * oldx(D1) * y(D7) + bcoo(A1);
moveq #5,d0
move.l d7,d5
bpl.b Pos4
neg.l d5
Pos4: move.l d5,d2
swap d5
mulu d5,d2
clr.w d2
swap d2
mulu d5,d5
add.l d2,d5
add.l d2,d5
asl.l d0,d5 ; q2(D4) = y(D7)^2;
bvs.b mandelexit
move.l d6,d4
bpl.b Pos5
neg.l d4
Pos5: move.l d4,d2
swap d4
mulu d4,d2
clr.w d2
swap d2
mulu d4,d4
add.l d2,d4
add.l d2,d4
asl.l d0,d4 ; q1(D4) = x(D6)^2;
bvs.b mandelexit
move.l d4,d0
add.l d5,d0
bvs.b mandelexit
cmpi.l #536870912,d0 ;$8000000 * 4
bgt.b mandelexit
dbf d3,mandelloop2
moveq #1,d3
mandelexit: subq.w #1,d3
move.l d3,d0
movem.l (a7)+,d1-d7/a2-a6
tst.w d0
beq.b nextx
movem.l d2-d4/a4,-(sp)
move.l d3,d2
lsr.w #3,d3
add.w d3,d4
and.w d7,d2
eor.b d6,d2
add.l d4,a4
lsr.w d0
bcc.b nobp0
bset.b d2,(a4)
nobp0: add.w a3,a4
lsr.w d0
bcc.b nobp1
bset.b d2,(a4)
nobp1: add.w a3,a4
lsr.w d0
bcc.b nobp2
bset.b d2,(a4)
nobp2: add.w a3,a4
lsr.w d0
bcc.b nobp3
bset.b d2,(a4)
nobp3: add.w a3,a4
lsr.w d0
bcc.b nobp4
bset.b d2,(a4)
nobp4:
pix_err: movem.l (sp)+,d2-d4/a4
nextx: sub.l d1,a0
btst #6,$bfe001
beq.b Mousewait
dbra d3,xloop
nexty: add.l d2,a1
add.w #40,d4
cmpi.w #(200*40),d4
blt.w yloop
MouseWait: btst #6,$bfe001
bne.b MouseWait
bsr.b RestoreSystem
rts ; Done!
***********************************************************
TakeSystem: movea.l 4,a6 ; ExecBase
jsr -$84(a6) ; Forbid() multitasking
lea $dff000,a5 ; Custom chip base
bsr.b InstallBmap
bsr.w InstallSprites
bsr.w InstallCopper
rts ; Done
***********************************************************
RestoreSystem: lea $dff000,a5
movea.l 4,a6 ; ExecBase
lea GraphicsName,a1 ; "graphics.library"
moveq.l #0,d0 ; Any version
jsr -$228(a6) ; OpenLibrary()
move.l d0,a1 ; Copy ptr to GfxBase
move.l $26(a1),$80(a5) ; Install old system copperlist
jsr -$19e(a6) ; CloseLibrary()
move.w DMACONSave,$96(a5) ; Activate old DMA channels
jsr -$8a(a6) ; Permit() multitasking
rts ; Done
***********************************************************
InstallBmap: lea bmapptrs,a0
move.l #Bmap,d0 ; say our bmap address is $12345678
move.w d0,6(a0) ; write $5678 to $e2 reg in copperlist
swap d0
move.w d0,2(a0) ; write $1234 to $e0
swap d0
add.l #8000,d0
move.w d0,14(a0)
swap d0
move.w d0,10(a0)
swap d0
add.l #8000,d0
move.w d0,22(a0)
swap d0
move.w d0,18(a0)
swap d0
add.l #8000,d0
move.w d0,30(a0)
swap d0
move.w d0,26(a0)
swap d0
add.l #8000,d0
move.w d0,38(a0)
swap d0
move.w d0,34(a0)
rts
***********************************************************
InstallCopper: move.l #Copper,$80(a5) ; install copper
rts
***********************************************************
InstallSprites: lea sprptrs,a0
move.l #NullSprite,d0
move.w d0,6(a0)
move.w d0,14(a0)
move.w d0,22(a0)
move.w d0,30(a0)
move.w d0,38(a0)
move.w d0,46(a0)
move.w d0,54(a0)
move.w d0,62(a0)
swap d0
move.w d0,2(a0)
move.w d0,10(a0)
move.w d0,18(a0)
move.w d0,26(a0)
move.w d0,34(a0)
move.w d0,42(a0)
move.w d0,50(a0)
move.w d0,58(a0)
rts
***********************************************************
section squid,data_c
GraphicsName: dc.b 'graphics.library',0
EVEN
Copper:
dc.w $1fc,0
dc.w $106,$c40
dc.w $0100,$5200 ; bit plane control reg.0
dc.w $0102,$0000 ; scroll value
dc.w $0104,$0000 ; blp/sprite priority reg.
dc.w $0108,$0000 ; odd bitplane modulo value
dc.w $010a,$0000 ; even bitplane modulo value
dc.w $0180,$0000
dc.w $0182,$0100
dc.w $0184,$0200
dc.w $0186,$0300
dc.w $0188,$0400
dc.w $018a,$0500
dc.w $018c,$0600
dc.w $018e,$0700
dc.w $0190,$0800
dc.w $0192,$0900
dc.w $0194,$0a00
dc.w $0196,$0b00
dc.w $0198,$0c00
dc.w $019a,$0d00
dc.w $019c,$0e00
dc.w $019e,$0f00
dc.w $01a0,$0fb0
dc.w $01a2,$0001
dc.w $01a4,$0002
dc.w $01a6,$0003
dc.w $01a8,$0004
dc.w $01aa,$0005
dc.w $01ac,$0006
dc.w $01ae,$0007
dc.w $01b0,$0008
dc.w $01b2,$0009
dc.w $01b4,$000a
dc.w $01b6,$000b
dc.w $01b8,$000c
dc.w $01ba,$000d
dc.w $01bc,$000e
dc.w $01be,$000f
dc.w $008e,$2c81 ; upper left corner of disp. window
dc.w $0090,$f4c1 ; lower right corner of disp. window
dc.w $0092,$0038 ; start of bpl. (horizontal)
dc.w $0094,$00d0 ; endo of bpl. (horizontal)
bmapptrs:
dc.w $00e0,$0000 ; adr of bplane 1 (long - 2 words)
dc.w $00e2,$0000 ; low word of bplane 1 adr
dc.w $00e4,$0000
dc.w $00e6,$0000
dc.w $00e8,$0000
dc.w $00ea,$0000
dc.w $00ec,$0000
dc.w $00ee,$0000
dc.w $00f0,$0000
dc.w $00f2,$0000
sprptrs:
dc.w $0120,$0000
dc.w $0122,$0000
dc.w $0124,$0000
dc.w $0126,$0000
dc.w $0128,$0000
dc.w $012a,$0000
dc.w $012c,$0000
dc.w $012e,$0000
dc.w $0130,$0000
dc.w $0132,$0000
dc.w $0134,$0000
dc.w $0136,$0000
dc.w $0138,$0000
dc.w $013a,$0000
dc.w $013c,$0000
dc.w $013e,$0000
dc.w $ffff,$fffe
Bmap: dcb.b 8000*5,0
***********************************************************
section farb,bss_c
NullSprite: ds.l 3 ; 2 control words/2 data words/2 blank words
DMACONSave: ds.w 1
INTENASave: ds.w 1
Level3Save: ds.l 1